package com.ewzj.bigdata.app.extensions

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ewzj.bigdata.R
import com.ewzj.bigdata.mvp.ui.adapter.HomePageAdapter
import com.jess.arms.base.BaseApplication
import com.jess.arms.integration.RepositoryManager
import com.jess.arms.widget.imageloader.glide.GlideImageConfig
import io.rx_cache2.internal.RxCache


/**
 * author:zhangjing
 * 作用:
 * return:
 */
fun ImageView.loadImgwithloading(url: String):Unit{
        var imgurl:String="error"
        if (!url.isNullOrEmpty()){
                imgurl=url
        }
        val application=this.context.applicationContext as BaseApplication
        val imageloader=application.appComponent.imageLoader()
        val imgconfig= GlideImageConfig.builder().errorPic(R.drawable.ic_loading)
                .placeholder(R.drawable.ic_loading)
                .url(imgurl)
                .imageView(this)
                .build()
        imageloader.loadImage(context,imgconfig)

}

fun RepositoryManager.getRxcache():RxCache{
        return this.getRxcache()
}